package com.example.demo.database

import androidx.room.TypeConverter
import java.sql.Date
import java.sql.Timestamp

class Converters {

    @TypeConverter
    fun toTimestamp(value: Long?): Timestamp? {
        return value?.let { Timestamp(it) }
    }

    @TypeConverter
    fun fromTimestamp(date: Timestamp?): Long? {
        return date?.time
    }

    @TypeConverter
    fun toDate(value: String?): Date?{
        return value?.let { Date.valueOf(value) }
    }

    @TypeConverter
    fun fromDate(date: Date?): String?{
        return date?.toString()
    }
}